<?php
//设置编码
header('Content-type:text/html;charset=utf-8;');

//包含函数库
include '../../public/func.php';

//接值LOGO文件
$_FILES;

//判断用户是否上传头像
if($_FILES['pic']['error'] != 4){
	//调用上传函数
	$logo =  upload('pic','../../uploads');
	//调用缩放函数
	$newlogo = suofang('../../uploads/'.basename($logo),129,66,'../../uploads/');
	//删除缩放前的原图
	if(isset($newlogo)){
		unlink('../../uploads/'.basename($logo));
	}
	$_POST['WZ_LOGO'] = $newlogo;
}

//拼接网站配置信息
$str = "<?php\n";
foreach($_POST as $val => $key){
	$str .= "const {$val} = '{$key}';\n";
}

//覆盖写入到文件中
if(file_put_contents('../../public/wzpeizhi.php',$str)){
	echo '<script>alert("修改网站配置成功");window.location.href="edit.php";</script>';
}else{
	echo '<script>alert("修改网站配置失败");window.location.href="edit.php";</script>';
}


